/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package cognitivetouch.colorSpan;

import org.lwjgl.LWJGLException;
import org.lwjgl.input.Mouse;

/**
 *
 * @author Xiaoxing
 */
public class MouseLib {

    public void initMouse() {
        //Mouse
        try {
            Mouse.setGrabbed(false);
            Mouse.create();
        } catch (LWJGLException e) {
            System.out.println(e.toString());
        }
    }

    public int[] processMouse() {
//        if (Mouse.isButtonDown(0)) {
//            mouseX = Mouse.getX();
//            mouseY = Mouse.getY();
//        }

        int mouseX = -1;
        int mouseY = -1;

        while (Mouse.next()) {
            if (Mouse.getEventButton()==0) {
                mouseX = Mouse.getEventX();
                mouseY = Mouse.getEventY();
            }
        }

        int[] coord = {mouseX, mouseY};
        return coord;
    }
    
    public void destroy(){
        Mouse.destroy();
    }
}
